package com.guoxin.part1.chapter3;

import java.util.stream.IntStream;

/**
 * @author guoxin
 * @date 2019/8/27
 */
public class ThreadYield {
    public static void main(String[] args) {
        IntStream.range(0,2).mapToObj(ThreadYield::create).forEach(Thread::start);
    }

    private static Thread create(int index){
        return new Thread(() -> {
            if(index==0){
                Thread.yield();
            }
            System.out.println(index);
        });
    }
}
